#include <iostream>
#include <vector>
using namespace std;

int most_short(vector<vector<int>> &gh, int status, int u, vector<vector<int>> &dp)
{
	if (dp[status][u] != -1) {
		return dp[status][u];
	}

        int n = gh.size();
	if (status == ((1 << n) - 1)) {
		return gh[u][0];
	}
	int ans = INT32_MAX;
	for (int i = 1; i < n; i++) {
		if ((status & (1 << i)) == 0) {
			ans = min(ans, gh[u][i] + most_short(gh, status | (1 << i), i, dp));
		}
	}

	return dp[status][u] = ans;
}

int main()
{
	int n = 0;
	cin >> n;
	vector<vector<int>> gh(n, vector<int>(n, 0));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> gh[i][j];
		}
	}

	vector<vector<int>> dp(1 << n, vector<int>(n, -1));

	cout << most_short(gh, 1, 0, dp) << endl;

	return 0;
}